package br.edu.ufcg.lsd.wbis;

import java.sql.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.After;
import org.junit.Before;

import br.edu.ufcg.lsd.wbis.control.util.HibernateUtil;

/**
 * General test case for dealing with the database.
 * 
 * @author Renato Miceli
 */
public abstract class DatabaseTestCase {

	protected Session session;

	@Before
	public void setUp() throws Exception {
		SessionFactory sessionFactory = HibernateUtil.getInstance(HibernateUtil.getTestingConfigFilePath()).getSessionFactory();
		session = sessionFactory.openSession();
	}

	@After
	public void tearDown() throws Exception {
		if(session != null){
			session.disconnect();
		}
		session = null;
	}

	protected static Date getDate(){
		return new Date(System.currentTimeMillis());
	}
	
}
